HTML <section> tag

The <section> tag defines sections in a document, such as chapters, headers, footers, or any other sections of the document. It’s used to split a page into sections like Introduction, Contact Information, Details, etc., and each of these sections can be in a different <section> tag. The <section> tag is introduced to wrap up things in a particular section. The <section> tag divides the content into sections and subsections.

Note: By default <section> element is of block-level.

Example: This example shows the use case of <section> tag on our web page.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>Section Tag</title>
    <style>
        .container {
            width: 400px;
            height: 400px;
            background-color: #dadada;
            margin: auto;
        }        
        div>section {
            height: calc(100%/3);
            width: 100%;
            font-size: 2rem;
            font-weight: 500;
        }        
        div>section:nth-of-type(2n) {
            background-color: green;
            color: white;
        }        
        .sub {
            font-size: 1.2rem;
            font-weight: 400;
        }
    </style>
</head>

<body>
    <div class="container">
        <section> Section 1 - Education
            <section class="sub">Subsection 1 - About College</section>
            <section class="sub">Subsection 2 - About School</section>
        </section>
        <section>Section 2 - Hobbies</section>
        <section>Section 3 - Contact Info</section>
    </div>
</body>
</html>

Output:

Differentiate between , & tags in HTML

HTML is a language full of diverse elements, and three such elements are the <article><p>, and <section> tags. These semantic tags, while similar, each have unique uses and meanings within an HTML document.

The article tag is used for the independent content, p tag for paragraph and section for different section of the document.

Tags in HTML are keywords where every specific single tag has some unique meaning.

Similar Reads

HTML

HTML

tag

The 

 tag, standing for ‘paragraph’, defines paragraphs in HTML. Anything written within 

 and 

 is treated as a paragraph. The browser automatically adds space (a single blank line) before and after each 

 element, which is simply margins added by the browser. Multiple lines and spaces added by the users are reduced to a single space by the browser. The 

 tag is most useful when there are multiple paragraphs to be added in articles, stories, etc....

HTML

tag

The 

 tag defines sections in a document, such as chapters, headers, footers, or any other sections of the document. It’s used to split a page into sections like Introduction, Contact Information, Details, etc., and each of these sections can be in a different 
 tag. The 
 tag is introduced to wrap up things in a particular section. The 
 tag divides the content into sections and subsections....

Difference between

tag,

tag &

tag in HTML:

tag                                      

tag                         

tag      Article tag is a semantic tag. Paragraph is presentational and semantic tag. Section tag is a semantic tag. When to use: Blog articleNewspapers/ Magazines articleForum PostWhen to use: Adding multiple paragraphs in articles, stories, informative blogs.When to use: Adding multiple headers or sections in a document.Default CSS display property is               “Block”Default CSS display property is “Block”                       Default CSS display property is “Block”...